:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #64748b;
    --danger: #ef4444;
    --success: #10b981;
    --warning: #f59e0b;
    --text-light: #f8fafc;
    --text-gray: #94a3b8;
    --glass-bg: rgba(20, 20, 20, 0.6);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0f172a;
    color: var(--text-light);
    overflow: hidden; /* Prevent body scroll, windows scroll internally */
    height: 100vh;
    width: 100vw;
    user-select: none; /* Desktop feel */
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0,0,0,0.1);
}
::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.2);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255,255,255,0.3);
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* Background Video */
#bg-video {
    position: fixed;
    right: 0;
    bottom: 0;
    min-width: 100%;
    min-height: 100%;
    width: auto;
    height: auto;
    z-index: -1;
    object-fit: cover;
    filter: brightness(0.6);
}

/* Custom Cursor */
#custom-cursor {
    position: fixed;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 10000;
    transform: translate(-50%, -50%);
    mix-blend-mode: difference;
    transition: transform 0.1s, background 0.2s;
}

.spark-trail {
    position: fixed;
    width: 4px;
    height: 4px;
    background: rgba(59, 130, 246, 0.8);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
    animation: fadeOut 0.5s forwards;
}

@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translate(-50%, -50%) scale(0);
    }
}

/* =========================================
   Header (Top Bar)
   ========================================= */
.header {
    height: 32px;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: white;
}

.header-logo img {
    height: 18px;
    width: auto;
}

/* =========================================
   Desktop Area
   ========================================= */
#desktop-area {
    position: absolute;
    top: 32px;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: hidden;
}

/* Desktop Icons */
.desktop-icons-container {
    position: absolute;
    top: 20px;
    left: 20px;
    bottom: 80px; /* Space for dock */
    display: flex;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: flex-start;
    gap: 16px;
    z-index: 5;
    pointer-events: none;
}

.desktop-icon {
    width: 84px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer !important;
    pointer-events: auto;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s;
    text-align: center;
}

.desktop-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.desktop-icon-img {
    width: 48px;
    height: 48px;
    margin-bottom: 6px;
    /* Drop shadow for icon visibility */
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.5)); 
}

.desktop-icon-label {
    color: white;
    font-size: 12px;
    line-height: 1.2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
    word-wrap: break-word;
    max-width: 100%;
    background: rgba(0,0,0,0.2); /* Legibility improvement */
    padding: 2px 6px;
    border-radius: 4px;
}

/* =========================================
   Window Manager
   ========================================= */
.window {
    position: absolute;
    background: #1e1e1e; /* Fallback */
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 10px;
    box-shadow: var(--glass-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s, opacity 0.2s, width 0.1s, height 0.1s;
    /* Default size set in JS */
}

.window-header {
    height: 38px;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    padding: 0 12px;
    cursor: default;
    user-select: none;
}

.window-controls {
    display: flex;
    gap: 8px;
    margin-right: 16px;
}

.control {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    cursor: pointer;
    position: relative;
}

.control.red { background: #ff5f56; border: 1px solid #e0443e; }
.control.yellow { background: #ffbd2e; border: 1px solid #dea123; }
.control.green { background: #27c93f; border: 1px solid #1aab29; }

.control:hover::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.1);
    border-radius: 50%;
}

.window-title {
    flex: 1;
    text-align: center;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-light);
    opacity: 0.9;
    margin-right: 52px; /* Balance the controls width */
}

.window-content {
    flex: 1;
    overflow: auto;
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    /* For standard WHMCS content */
    padding: 20px;
    color: var(--text-light);
}

/* If content is iframe, remove padding */
.window-content iframe {
    display: block;
}

/* Window States */
.window.window-minimized {
    transform: scale(0.8) translateY(100%);
    opacity: 0;
    pointer-events: none;
}

.window.window-maximized {
    top: 0 !important;
    left: 0 !important;
    width: 100% !important;
    height: 100% !important;
    border-radius: 0;
    border: none;
}

.resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 10;
}

/* =========================================
   Dock (Taskbar)
   ========================================= */
.dock-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 8px 12px;
    display: flex;
    gap: 12px;
    z-index: 2000;
    box-shadow: var(--glass-shadow);
}

.dock-item {
    width: 48px;
    height: 48px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s;
}

.dock-item:hover {
    transform: scale(1.1) translateY(-5px);
}

.dock-item img, .dock-item svg {
    width: 40px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

.dock-dot {
    position: absolute;
    bottom: -4px;
    width: 4px;
    height: 4px;
    background: var(--text-light);
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.2s;
}

.dock-item.active .dock-dot {
    opacity: 1;
}

.dock-tooltip {
    position: absolute;
    top: -40px;
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    white-space: nowrap;
}

.dock-item:hover .dock-tooltip {
    opacity: 1;
}

/* =========================================
   Start Menu
   ========================================= */
#start-menu {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    width: 600px;
    max-width: 90vw;
    height: 500px;
    background: rgba(30, 30, 30, 0.9);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    z-index: 1999;
    display: flex;
    flex-direction: column;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.2, 0.8, 0.2, 1);
}

#start-menu.active {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.start-search {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    padding: 12px 16px;
    border-radius: 6px;
    color: white;
    font-size: 14px;
    width: 100%;
    margin-bottom: 24px;
    outline: none;
}

.start-search:focus {
    border-color: var(--primary);
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 24px;
    overflow-y: auto;
    padding-bottom: 20px;
}

.app-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
}

.app-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.app-item img, .app-item svg {
    width: 48px;
    height: 48px;
}

.app-item span {
    font-size: 12px;
    text-align: center;
    color: var(--text-light);
}

/* =========================================
   Context Menu
   ========================================= */
#context-menu {
    position: fixed;
    background: rgba(40, 40, 40, 0.95);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 6px;
    padding: 4px;
    min-width: 200px;
    display: none;
    flex-direction: column;
    z-index: 9999;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

.context-item {
    padding: 8px 12px;
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
}

.context-item:hover {
    background: var(--primary);
    color: white;
}

.context-separator {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 4px 0;
}

/* =========================================
   WHMCS Internal Content Styling
   ========================================= */
/* Make standard WHMCS elements look good on dark background */
h1, h2, h3, h4, h5, h6 { color: white; margin-bottom: 1rem; }
p { margin-bottom: 1rem; line-height: 1.6; }

/* Tables */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
    background: rgba(255,255,255,0.05);
    border-radius: 8px;
    overflow: hidden;
}
.table th, .table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.table th {
    background: rgba(255,255,255,0.1);
    font-weight: 600;
}
.table tr:hover {
    background: rgba(255,255,255,0.02);
}

/* Forms */
input[type="text"], input[type="password"], input[type="email"], textarea, select {
    background: rgba(0,0,0,0.2);
    border: 1px solid rgba(255,255,255,0.1);
    color: white;
    padding: 8px 12px;
    border-radius: 4px;
    width: 100%;
    margin-bottom: 10px;
    outline: none;
}
input:focus, textarea:focus, select:focus {
    border-color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: var(--secondary);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
}
.btn:hover { filter: brightness(1.1); }
.btn-primary { background: var(--primary); }
.btn-success { background: var(--success); }
.btn-danger { background: var(--danger); }

/* Alerts */
.alert {
    padding: 12px;
    border-radius: 6px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-info { background: rgba(59, 130, 246, 0.2); border-color: rgba(59, 130, 246, 0.4); color: #93c5fd; }
.alert-success { background: rgba(16, 185, 129, 0.2); border-color: rgba(16, 185, 129, 0.4); color: #6ee7b7; }
.alert-danger, .alert-error { background: rgba(239, 68, 68, 0.2); border-color: rgba(239, 68, 68, 0.4); color: #fca5a5; }
.alert-warning { background: rgba(245, 158, 11, 0.2); border-color: rgba(245, 158, 11, 0.4); color: #fcd34d; }


/* =========================================
   Auth Pages (Login/Register)
   ========================================= */
.auth-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999 !important;
}

.auth-container {
    width: 800px;
    height: 500px;
    display: flex;
    background: rgba(10, 10, 10, 0.7);
    backdrop-filter: blur(40px) saturate(150%);
    -webkit-backdrop-filter: blur(40px) saturate(150%);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    overflow: hidden;
    position: relative;
    z-index: 100000 !important;
}

.glass-effect {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.auth-left {
    flex: 1;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1) 0%, rgba(37, 99, 235, 0.2) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.auth-right {
    flex: 1.2;
    padding: 40px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow-y: auto;
}

.auth-welcome h2 { font-size: 2rem; margin-bottom: 0.5rem; }
.auth-welcome h3 { font-size: 1.5rem; margin: 1rem 0; color: var(--primary); }

.auth-form-box h2 { font-size: 1.8rem; text-align: center; margin-bottom: 1.5rem; }

/* Affichage correct des pages auth en window_mode (dans une fenêtre) */
body.window-mode .auth-wrapper { 
    position: relative; 
    width: 100%; 
    height: auto; 
    display: block; 
}
body.window-mode .auth-container { 
    width: 100%; 
    max-width: none; 
    height: auto; 
    border-radius: 0; 
    box-shadow: none; 
}
body.window-mode .auth-left { display: none; }
body.window-mode .auth-right { padding: 24px; flex: 1; }

.auth-page .header, 
.auth-page #desktop-area, 
.auth-page #start-menu, 
.auth-page #dock-container,
.auth-page #context-menu,
.auth-page .resize-handle,
.auth-page .window {
    display: none !important;
}

/* Minimal overrides appended */
#app-missing-classes { display: none; } /* anchor for search */

#bg-video { position: fixed !important; inset: 0 !important; width: 100vw !important; height: 100vh !important; object-fit: cover !important; transform: none !important; z-index: -1 !important; }

#custom-cursor {
    width: 14px !important;
    height: 14px !important;
    background: #ff4d4d !important;
    border-radius: 50% !important;
    box-shadow: 0 0 10px 2px rgba(255, 50, 50, 0.8), 0 0 20px 5px rgba(255, 0, 0, 0.4) !important;
    position: fixed !important;
    pointer-events: none !important;
    z-index: 10000 !important;
    transform: translate(-50%, -50%) !important;
}

/* Hide OS default cursor only en mode bureau (pas sur login/register) */
body:not(.auth-page), 
body:not(.auth-page) *, 
body:not(.auth-page) a, 
body:not(.auth-page) button, 
body:not(.auth-page) input, 
body:not(.auth-page) select, 
body:not(.auth-page) textarea, 
body:not(.auth-page) iframe {
    cursor: none !important;
}

/* Classes utilisées par le contenu des fenêtres (ajouts non intrusifs) */
.browser-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
}

.url-bar {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 6px;
    padding: 4px 12px;
    color: var(--text-gray);
    font-size: 0.9rem;
    outline: none;
    text-overflow: ellipsis;
}

.content-inner {
    padding: 2rem;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.button {
    padding: 0.75rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.2s ease;
    cursor: pointer !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button-primary {
    background-color: var(--primary);
    color: white;
    border: none;
}

.button-primary:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.button-secondary {
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--text-light);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.button-secondary:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.badge {
    padding: 0.4rem 0.8rem;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border-radius: 9999px;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 1rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Form checkbox (auth pages) */
.form-checkbox {
    margin: 10px 0;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}
.form-checkbox input[type="checkbox"] {
    accent-color: var(--primary);
}

/* Auth logo sizing (avoid oversized image) */
.auth-logo img {
    width: 96px;
    height: 96px;
    object-fit: contain;
    border-radius: 12px;
}

/* Buttons for inputs used on auth pages */
input.btn-primary,
.auth-form .btn-primary {
    width: 100%;
    padding: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer !important;
}
input.btn-primary:hover,
.auth-form .btn-primary:hover {
    filter: brightness(1.07);
    transform: translateY(-1px);
}
